          /*           NUMCLUS.C           */
 # include <stdio.h>
 # include <dir.h>
 # include <conio.h>

 main()
  {
    struct ffblk fil ;
    char boot[512] , fname[50] , drv ;
    unsigned int bytes_per_sector , sectors_per_cluster , total ;
    int stat , drive , numclus ;

    clrscr() ;
    printf("\n\n\n      Enter the filename : ") ;
    gets(fname) ;
    drv = fname[0] ;
    drv = toupper(drv) ;
    drive = drv - 'A' ;
    stat = findfirst(fname,&fil,32) ;
    if ( stat == 0 )
     {
       printf("\n\n\n File size = %ld",fil.ff_fsize) ;
       absread(drive,1,0,boot) ;
       bytes_per_sector = boot[0x0C] ;
       bytes_per_sector = bytes_per_sector << 8 ;
       bytes_per_sector = bytes_per_sector | boot[0x0B] ;
       printf("\n\n\n Bytes per sector = %u",bytes_per_sector) ;
       sectors_per_cluster = boot[0x0D] ;
       printf("\n\n\n Sectors per cluster = %u",sectors_per_cluster) ;
       total = bytes_per_sector * sectors_per_cluster ;
       if (( fil.ff_fsize % total ) == 0 )
         numclus = fil.ff_fsize / total ;
       else
         numclus = fil.ff_fsize / total + 1 ;
       printf("\n\n\n      Number of clusters allocated to file is =  %d",numclus) ;
      }
    printf("\n\n          Press any key ...") ;
    getch() ;
   }
